<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Minim : : Minim</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body> 
<center>
<table class="mainTable">
  <tr>
    <td class="header">
    	<span class="indexheader">Minim</span><br/>
    	<span class="indexnavigation">
    		<a href="index.html">core</a> | 
    		<a href="index_ugens.html">ugens</a> | 
    		<a href="index_analysis.html">analysis</a>
    	</span>
    </td>
    <td class="border-left">&nbsp;</td>
  </tr>
  
  <tr>
    <td class="classNavigation">
    	<p class="mainTextName">Minim</p>
    	
       <p class="linkListHeader">Fields</p>
       <p class="linkList">
           
    <a href="minim_field_aifc.html" title="The .aifc file format.">AIFC</a><br/>
    
    <a href="minim_field_aiff.html" title="The .aiff file format.">AIFF</a><br/>
    
    <a href="minim_field_au.html" title="The .au file format.">AU</a><br/>
    
    <a href="minim_field_mono.html" title="Specifies that you want a MONO AudioInput or AudioOutput">MONO</a><br/>
    
    <a href="minim_field_snd.html" title="The .snd file format.">SND</a><br/>
    
    <a href="minim_field_stereo.html" title="Specifies that you want a STEREO AudioInput or AudioOutput">STEREO</a><br/>
    
    <a href="minim_field_wav.html" title="The .wav file format.">WAV</a><br/>
    
	   </p>
   
    	
       <p class="linkListHeader">Methods</p>
       <p class="linkList">
           
    <a href="minim_method_createrecorder.html" title="Creates an AudioRecorder.">createRecorder ( )</a><br/>
    
    <a href="minim_method_createsample.html" title="Creates an AudioSample using the provided sample data and AudioFormat.">createSample ( )</a><br/>
    
    <a href="minim_method_debugoff.html" title="Turns off debug messages.">debugOff ( )</a><br/>
    
    <a href="minim_method_debugon.html" title="Turns on debug messages.">debugOn ( )</a><br/>
    
    <a href="minim_method_getinputstream.html" title="Get the input as an AudioStream that you can read from yourself, rather
 than wrapped in an AudioInput that does that work for you.">getInputStream ( )</a><br/>
    
    <a href="minim_method_getlinein.html" title="get an AudioInput that reads from the active audio input of the soundcard">getLineIn ( )</a><br/>
    
    <a href="minim_method_getlineout.html" title="get an AudioOutput that can be used to generate audio">getLineOut ( )</a><br/>
    
    <a href="minim_method_loadfile.html" title="Loads the requested file into an AudioPlayer.">loadFile ( )</a><br/>
    
    <a href="minim_method_loadfileintobuffer.html" title="Loads the requested file into a MultiChannelBuffer.">loadFileIntoBuffer ( )</a><br/>
    
    <a href="minim_method_loadfilestream.html" title="Loads the file into an AudioRecordingStream.">loadFileStream ( )</a><br/>
    
    <a href="minim_method_loadsample.html" title="Loads the requested file into an AudioSample.">loadSample ( )</a><br/>
    
    <a href="minim_method_setinputmixer.html" title="When using the JavaSound implementation of Minim, this sets the JavaSound Mixer 
 that will be used for obtaining input sources such as AudioInputs.
 THIS METHOD WILL BE REPLACED IN A FUTURE VERSION.">setInputMixer ( )</a><br/>
    
    <a href="minim_method_setoutputmixer.html" title="When using the JavaSound implementation of Minim, this sets the JavaSound Mixer 
 that will be used for obtain output destinations such as those required by AudioOuput, 
 AudioPlayer, AudioSample, and so forth. 
 THIS METHOD WILL BE REPLACED IN A FUTURE VERSION.">setOutputMixer ( )</a><br/>
    
    <a href="minim_method_stop.html" title="Stops Minim and releases all audio resources.
 <p>
 If using Minim outside of Processing, you must call this to 
 release all of the audio resources that Minim has generated.
 It will call close() on all of them for you.">stop ( )</a><br/>
    
	   </p>
   
    </td>
    <td class="mainText border-left">
    	<p>
 The <code>Minim</code> class is the starting point for most everything
 you will do with this library. There are methods for obtaining objects for playing audio files:
 AudioSample and AudioPlayer. There are methods for obtaining an AudioRecorder, 
 which is how you record audio to disk. There are methods for obtaining an AudioInput, 
 which is how you can monitor the computer's line-in or microphone, depending on what the
 user has set as the record source. Finally there are methods for obtaining an AudioOutput, 
 which is how you can play audio generated by your program, typically by connecting classes 
 found in the ugens package. 
 </p>
 <p>
 Minim keeps references to all of the resources that are 
 returned from these various methods so that you don't have to worry about closing them.
 Instead, when your application ends you can simply call the stop method of your Minim instance.
 Processing users <em>do not</em> need to do this because Minim detects when a PApplet is passed 
 to the contructor and registers for a notification of application shutdown.
 </p>
 <p>
 Minim requires an Object that can handle two important
 file system operations so that it doesn't have to worry about details of 
 the current environment. These two methods are:
 </p>
 <pre>
 String sketchPath( String fileName )
 InputStream createInput( String fileName )
 </pre>
 <p>
 These are methods that are defined in Processing, which Minim was originally 
 designed to cleanly interface with. The <code>sketchPath</code> method is 
 expected to transform a filename into an absolute path and is used when 
 attempting to create an AudioRecorder. The <code>createInput</code> method 
 is used when loading files and is expected to take a filename, which is 
 not necessarily an absolute path, and return an <code>InputStream</code> 
 that can be used to read the file. For example, in Processing, the <code>createInput</code>
 method will search in the data folder, the sketch folder, handle URLs, and absolute paths.
 If you are using Minim outside of Processing, you can handle whatever cases are 
 appropriate for your project.
 </p>
    	<p class="memberSectionHeader">Constructors</p>
    	<pre><em>Creates an instance of Minim.
 <p>
 Minim requires an Object that can handle two important
 file system operations so that it doesn't have to worry about details of 
 the current environment. These two methods are:
 </p>
 <pre>
 String sketchPath( String fileName )
 InputStream createInput( String fileName )
 </pre>
 <p>
 These are methods that are defined in Processing, which Minim was originally 
 designed to cleanly interface with. The <code>sketchPath</code> method is 
 expected to transform a filename into an absolute path and is used when 
 attempting to create an AudioRecorder. The <code>createInput</code> method 
 is used when loading files and is expected to take a filename, which is 
 not necessarily an absolute path, and return an <code>InputStream</code> 
 that can be used to read the file. For example, in Processing, the <code>createInput</code>
 method will search in the data folder, the sketch folder, handle URLs, and absolute paths.
 If you are using Minim outside of Processing, you can handle whatever cases are 
 appropriate for your project.
 </p></em>
Minim(Object fileSystemHandler)
</pre>
    	
   <p class="memberSectionHeader">Parameters</p>
   
        <span class="parameterName">fileSystemHandler</span>&nbsp;&mdash;&nbsp;<span class="parameterDescription">The Object that will be used for file operations.
            When using Processing, simply pass <strong>this</strong> to Minim's constructor.</span><br/>
    
   
    	<p class="memberSectionHeader">Related</p>
    	
    	<p class="memberSectionHeader">Example</p>
    	<pre>/**
  * This sketch demonstrates how to play a file with Minim using an AudioPlayer. &lt;br />
  * It's also a good example of how to draw the waveform of the audio. Full documentation 
  * for AudioPlayer can be found at http://code.compartmental.net/minim/audioplayer_class_audioplayer.html
  * &lt;p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/
  */

import ddf.minim.*;

Minim minim;
AudioPlayer player;

void setup()
{
  size(512, 200, P3D);
  
  // we pass this to Minim so that it can load files from the data directory
  minim = new Minim(this);
  
  // loadFile will look in all the same places as loadImage does.
  // this means you can find files that are in the data folder and the 
  // sketch folder. you can also pass an absolute path, or a URL.
  player = minim.loadFile("groove.mp3");
}

void draw()
{
  background(0);
  stroke(255);
  
  // draw the waveforms
  // the values returned by left.get() and right.get() will be between -1 and 1,
  // so we need to scale them up to see the waveform
  // note that if the file is MONO, left.get() and right.get() will return the same value
  for(int i = 0; i &lt; player.bufferSize() - 1; i++)
  {
    float x1 = map( i, 0, player.bufferSize(), 0, width );
    float x2 = map( i+1, 0, player.bufferSize(), 0, width );
    line( x1, 50 + player.left.get(i)*50, x2, 50 + player.left.get(i+1)*50 );
    line( x1, 150 + player.right.get(i)*50, x2, 150 + player.right.get(i+1)*50 );
  }
  
  // draw a line to show where in the song playback is currently located
  float posx = map(player.position(), 0, player.length(), 0, width);
  stroke(0,200,0);
  line(posx, 0, posx, height);
  
  if ( player.isPlaying() )
  {
    text("Press any key to pause playback.", 10, 20 );
  }
  else
  {
    text("Press any key to start playback.", 10, 20 );
  }
}

void keyPressed()
{
  if ( player.isPlaying() )
  {
    player.pause();
  }
  // if the player is at the end of the file,
  // we have to rewind it before telling it to play again
  else if ( player.position() == player.length() )
  {
    player.rewind();
    player.play();
  }
  else
  {
    player.play();
  }
}</pre>
    	<p class="memberSectionHeader">Usage</p>
    	Web & Application
    </td>
  </tr>
</table>
</center>
</body>
</html>